<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>弹窗居中布局</title>
</head>

<body>
    <div class="box">
        <div class="mask"></div>
        <div class="content">
            <div class="bg-top">
                <h1>弹窗居中布局</h1>
            </div>
        </div>
    </div>
    <style>
        .box .mask {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 1000;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.45);
        }

        .box .content::before {
            display: inline-block;
            width: 0;
            height: 100%;
            vertical-align: middle;
            content: "";
        }

        .box .content {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            overflow: auto;
            outline: 0;
            -webkit-overflow-scrolling: touch;
            z-index: 1000;
            text-align: center;
        }

        .box .content .bg-top {
            top: 0;
            display: inline-block;
            padding-bottom: 0;
            text-align: left;
            vertical-align: middle;
            width: auto !important;
            box-sizing: border-box;
            padding: 0;
            color: #3d3d3d;
            font-size: 12px;
            font-variant: tabular-nums;
            line-height: 1.5715;
            list-style: none;
            font-feature-settings: "tnum";
            pointer-events: none;
            position: relative;
            max-width: calc(100vw - 32px);
            margin: 0 auto;
        }
    </style>

</body>

</html>